package com.aaa.hospital.service.impl;


import com.aaa.hospital.mapper.NewsAgreeMapper;
import com.aaa.hospital.mapper.NewsStateMapper;
import com.aaa.hospital.pojo.domain.News;
import com.aaa.hospital.pojo.query.NewsStateQuery;
import com.aaa.hospital.result.AjaxResult;
import com.aaa.hospital.service.NewsStateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;

/**
 * @program:qy888
 * @description:www
 * @author:LJW
 * @version: 1.0
 * @create:2022-12-17 21:23
 */
@Service
public class NewsStateServiceImpl  implements NewsStateService {

    @Autowired
    private NewsStateMapper newsStateMapper;

    @Override
    public AjaxResult queryNewsState(NewsStateQuery newsStateQuery) {

        List<News> news = newsStateMapper.queryNewsState(newsStateQuery);

        Long aLong = newsStateMapper.queryNewsStateTotal(newsStateQuery);

        HashMap<Object,Object> objectObjectHashMap = new HashMap<>();

        objectObjectHashMap.put("currentData",news);
        objectObjectHashMap.put("totalCount",aLong);

        return AjaxResult.success(objectObjectHashMap);
    }

    @Override
    public AjaxResult upper(Integer id) {
        int i = newsStateMapper.upper(id);
        return AjaxResult.success();
    }

    @Override
    public AjaxResult lower(Integer id) {
        int i = newsStateMapper.lower(id);
        return AjaxResult.success();
    }

    @Override
    public AjaxResult get(Integer id) {
        News n = newsStateMapper.buByID(id);
        return AjaxResult.success(n);
    }

//    @Override
//    public AjaxResult get(Integer id){
//        News n = newsStateMapper.seeByID(id);
//        return AjaxResult.success(n);
//    }
}
